package com.zrx.govern.component.easyexcel.starter.enums;

import com.alibaba.excel.support.ExcelTypeEnum;
import lombok.AllArgsConstructor;
import lombok.Getter;
import org.springframework.util.StringUtils;

/**
 * @author zhangxiaowei
 * @version V1.0
 */
@Getter
@AllArgsConstructor
public enum ExcelEnum {
    /**
     * xls
     */
    XLS(".xls","application/vnd.ms-excel"),
    XLSX(".xlsx","application/vnd.openxmlformats-officedocument.spreadsheetml.sheet");

    private String value;

    private String contentType;

    public static ExcelEnum getExcelEnumByValue(String value) {
        for (ExcelEnum excelEnum : ExcelEnum.values()) {
            if (value.equalsIgnoreCase(excelEnum.getValue())) {
                return excelEnum;
            }
        }
        return ExcelEnum.XLSX;
    }


    public static ExcelTypeEnum getExcelTypeEnumByValue(ExcelEnum excelEnum) {
        if (excelEnum.getValue().equalsIgnoreCase(ExcelTypeEnum.XLS.getValue())) {
            return ExcelTypeEnum.XLS;
        }
        return ExcelTypeEnum.XLSX;
    }

}
